from multiprocessing import Process, Array


# 创建共享内存
# 共享内存开辟5个整型列表空间

def fun(shm):
    for i in shm:
        print(i)
    #     修改共享内存
    # shm[1] = 1000
    shm[1] = b'H'


if __name__ == "__main__":
    # shm = Array('i', 5)
    # shm = Array('i', [1, 2, 3])
    shm = Array('c', b'hello')
    p = Process(target=fun, args=(shm,))
    p.start()
    p.join()

    for i in shm:
        print(i, end=' ')

    # 通过value属性访问字节串
    print(shm.value)
